package tech.aistar.corejava.day13;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @Author: lya
 * @Description: 本类的作用描述:
 * @CreateDate: 2019/8/2
 * @Version: 1.0
 */
public class FileReaderDemo {
    public static void main(String[] args) {
        BufferedReader br = null;

        try {
            br = new BufferedReader(new FileReader("src/tech/aistar/corejava/day13/ByteIODemo.java"));

            while(true){
//                int len = br.read();//读取单个字符
//                if(len == -1){
//                    break;
//                }
//                System.out.print(len);
//
                String line = br.readLine();//读取文件中的一整行

                if(line == null){
                    break;
                }
                System.out.println(line);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(null != br){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
